#!/usr/bin/env bash

#CONFIG="$HOME/.config/hypr/foot/foot.ini"

if [ "$1" == "-f" ]; then
	kitty --class 'kitty-float'
elif [ "$1" == "-F" ]; then
	kitty --class 'kitty-full'
elif [ "$1" == "-s" ]; then
	# foot --app-id='foot-float' --config="$CONFIG" \
	# --window-size-pixels=$(slurp -b 20262CCC -c B4A1DBff -s B4A1DB0D -w 2 -f "%wx%h")
	# Use slurp to select an area
	# Path to the custom kitty config file
	KITTY_CUSTOM_CONF="$HOME/.config/kitty/kitty-custom.conf"

	# Use slurp to select an area
	geometry=$(slurp -f "%h %w %X %Y")

	# Check if slurp was successful
	if [ -z "$geometry" ]; then
		exit 1
	fi

	# Extract coordinates and dimensions
	read -r h w X Y < <(echo $geometry | awk -F'[x+]' '{print $1, $2, $3, $4}')

	# Create the custom kitty config file
	echo "include kitty.conf" > "$KITTY_CUSTOM_CONF"
	echo "initial_window_width ${w}" >> "$KITTY_CUSTOM_CONF"
	echo "initial_window_height ${h}" >> "$KITTY_CUSTOM_CONF"

	# Launch kitty with the custom config
	kitty --config "$KITTY_CUSTOM_CONF" --class "kitty-float"
else
	kitty
fi
